package com.ask.mapper;

import com.ask.annotation.AutoFill;
import com.ask.dto.EmployeePageQueryDTO;
import com.ask.entity.Employee;
import com.ask.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {
    /**
     * 新增员工
     * @param employee
     */
    @Insert("insert into employee (name, username, password,phone, sex," +
            "id_number, create_time, update_time, create_user,update_user,status) " +
            "values" +
            "(#{name}, #{username}, #{password},#{phone}, #{sex}, " +
            "#{idNumber}, #{createTime}, #{updateTime}, #{createUser}, " +
            "#{updateUser}, #{status})")
    @AutoFill(value = OperationType.INSERT)
    void insert(Employee employee);

    /**
     * 根据id查询记录
     * @param id
     * @return
     */
    @Select("select * from employee where id = #{id}")
    Employee getById(Long id);

    /**
     * 跟新员工
     * @param employee
     */

    @AutoFill(value = OperationType.UPDATE)
    void update(Employee employee);

    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    @Select("select * from employee where username = #{username}")
    Employee getByUserName(String username);
}
